package com.lei.design.observer;

/**
 * @Author LeiXiaoLei
 * @Date 2022/5/12 21:35
 * @Version 1.0
 */
public class Main {
    public static void main(String[] args) {
        WeatherData weatherData = new WeatherData();
        CurrentConditionsDisplay currentConditionsDisplay = new CurrentConditionsDisplay(weatherData);
        ForecastDisplay forecastDisplay = new ForecastDisplay(weatherData);
        StatisticsDisplay statisticsDisplay = new StatisticsDisplay(weatherData);
        ThirdPartyDisplay thirdPartyDisplay = new ThirdPartyDisplay(weatherData);

        System.out.println("**********************************************");
        weatherData.setMeasurements(80,65,30.4f);
        System.out.println("**********************************************");
        weatherData.setMeasurements(82,15,20.4f);
        System.out.println("**********************************************");
        weatherData.setMeasurements(85,25,40.4f);
        weatherData.removeObserver(forecastDisplay);
        weatherData.removeObserver(statisticsDisplay);
        weatherData.removeObserver(thirdPartyDisplay);
        System.out.println("**********************************************");
        weatherData.setMeasurements(19,35,50.4f);
        System.out.println("**********************************************");
    }
}
